<template>
    <div class="filter">
        <div class="filter-item">
            <label for="">所属单位：</label>
            <el-select
                v-model="searchForm.depId"
                class="m-2"
                placeholder="请选择所属单位"
                style="width: 145px"
                :disabled="localTypeUnit != '1'"
            >
                <el-option
                    v-for="item in depIdList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                />
            </el-select>
        </div>
        <div class="filter-item">
            <label for="">任务状态：</label>
            <el-select
                v-model="searchForm.status"
                class="m-2"
                placeholder="请选择任务状态"
                style="width: 145px"
            >
                <el-option
                    v-for="item in statusList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                />
            </el-select>
        </div>
        <div class="filter-item">
            <label for="">验收状态：</label>
            <el-select
                v-model="searchForm.acceptanceStatus"
                class="m-2"
                placeholder="请选择验收状态"
                style="width: 145px"
            >
                <el-option
                    v-for="item in acceptanceStatusList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                />
            </el-select>
        </div>
        <div class="filter-item">
            <label for="">设备名称：</label>
            <el-input
                v-model="searchForm.facilityName"
                placeholder="请输入设备名称"
                style="width: 155px"
            />
        </div>
        <div class="filter-item">
            <label for="">资产编号：</label>
            <el-input
                v-model="searchForm.assetNumber"
                placeholder="请输入资产编号"
                style="width: 155px"
            />
        </div>
        <div class="filter-item">
            <label for="">时间：</label>
            <el-date-picker
                style="width: 260px"
                v-model="searchForm.dateTime"
                type="daterange"
                unlink-panels
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                :size="'default'"
                :clearable="false"
            />
        </div>
        <div class="filter-item">
            <el-button
                size="default"
                type="primary"
                @click="search"
            >查询</el-button>
            <el-button
                size="default"
                type="primary"
                @click="reset"
            >重置</el-button>
            <!-- <el-button size="default" type="success" @click="updateTask"
                >更新任务</el-button
            > -->
        </div>
    </div>

    <div class="filter">
        <div
            class="filter-item"
            style="flex: 1"
        >
            <el-button
                size="default"
                type="success"
                @click="batchCheckAccept"
            >批量验收</el-button>
        </div>
        <div class="choiceListNumb">
            <span>已选: {{ rowDataList.length || 0 }} 项</span>
            <el-button
                type="text"
                @click="clearSelect"
            >清除</el-button>
        </div>
    </div>

    <el-table
        ref="multipleTableRef"
        :data="tableData"
        border
        style="width: 100%"
        :row-key="getRowKey"
        @selection-change="handleSelectionChange"
    >
        <el-table-column
            type="selection"
            width="55"
            :reserve-selection="true"
        />
        <el-table-column
            type="index"
            label="序号"
            width="55"
        />
        <el-table-column
            prop="facilityName"
            label="设备名称"
        />
        <el-table-column
            prop="facilityLocations"
            label="安装位置"
        />
        <el-table-column
            prop="specificationModel"
            label="设备型号"
        />
        <el-table-column
            prop="assetNumber"
            label="资产编号"
            width="120"
        />
        <el-table-column
            prop="failureDesc"
            label="故障描述"
            width="160"
        />
        <el-table-column
            prop="reportDate"
            label="报修日期"
        />
        <el-table-column
            prop="reportUser"
            label="报修人"
        />
        <el-table-column
            prop="status"
            label="任务状态"
        >
            <template #default="scope">
                {{ statusName(scope.row.status + "") }}
            </template>
        </el-table-column>
        <el-table-column
            prop="repairUser"
            label="维修人"
        />
        <el-table-column
            prop="acceptanceStatus"
            label="验收状态"
        >
            <template #default="scope">
                {{ upkeepLevelName(scope.row.acceptanceStatus + "") }}
            </template>
        </el-table-column>
        <el-table-column
            prop="acceptanceUser"
            label="验收人"
        />
        <el-table-column
            fixed="right"
            label="操作"
            width="190"
        >
            <template #default="scope">
                <el-button
                    v-if="isEquipmentManager || isAdmin"
                    text
                    type="warning"
                    size="small"
                    style="margin: 0"
                    :disabled="
                        scope.row.status == '100' || scope.row.status == '90'
                    "
                    @click="optionAdjust(scope.row)"
                >
                    处理
                </el-button>
                <el-button
                    v-if="isEquipmentManager || isAdmin"
                    text
                    type="success"
                    size="small"
                    style="margin-left: 0"
                    :disabled="scope.row.acceptanceStatus != '90'"
                    @click="optionCheckAccept(scope.row)"
                >
                    验收
                </el-button>
                <el-button
                    text
                    type="primary"
                    size="small"
                    style="margin-left: 0"
                    :disabled="scope.row.status != '10'"
                    @click="reportTask(scope.row)"
                >
                    填报
                </el-button>
                <el-button
                    text
                    type="info"
                    size="small"
                    style="margin-left: 0"
                    @click="optionRecord(scope.row)"
                >
                    操作记录
                </el-button>
            </template>
        </el-table-column>
    </el-table>
    <el-pagination
        v-model:current-page="searchForm.pageNo"
        v-model:page-size="searchForm.pageSize"
        layout="total, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        class="paginationStyle"
    />
    <el-dialog
        v-model="recordListVisible"
        title="操作记录"
        width="1000"
    >
        <div class="filter">
            <div class="filter-item">
                <label for="">操作时间：</label>
                <el-date-picker
                    style="width: 240px"
                    v-model="recordTime"
                    type="daterange"
                    unlink-panels
                    range-separator="至"
                    start-placeholder="开始时间"
                    end-placeholder="结束时间"
                    :size="'default'"
                    :shortcuts="shortcuts"
                />
            </div>
            <div class="filter-item">
                <el-button
                    size="default"
                    type="warning"
                    @click="searchRecord(currentRowRecord)"
                >查询</el-button>
            </div>
        </div>
        <el-table
            :data="recordList"
            style="width: 100%"
        >
            <el-table-column
                prop="operationType"
                label="操作类型"
            />
            <el-table-column
                prop="createTime"
                label="操作时间"
                width="160"
            />
            <el-table-column
                prop="comment"
                label="操作内容"
                width="560"
            />
            <el-table-column
                prop="operationRealname"
                label="操作人"
            />
        </el-table>
        <el-pagination
            v-model:current-page="recordPageNo"
            v-model:page-size="recordPageSize"
            layout="total, prev, pager, next, jumper"
            :total="totalRecord"
            @size-change="handleSizeChangeRecord"
            @current-change="handleCurrentChangeRecord"
            class="paginationStyle"
        />
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="recordListVisible = false">取消</el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog
        v-model="adjustVisible"
        title="处理"
        width="600"
    >
        <el-form label-width="120">
            <el-form-item
                label="处理结果："
                prop="name"
            >
                <el-select
                    v-model="adjustType"
                    placeholder=""
                    style="width: 200px"
                >
                    <el-option
                        v-for="item in adjustList"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                    />
                </el-select>
            </el-form-item>
            <el-form-item
                label="分配维修人"
                prop="inspectionUser"
                v-show="adjustType == '确认故障'"
            >
                <el-select
                    v-model="inspectionUser"
                    placeholder="请选择分配维修人"
                    style="width: 200px"
                >
                    <el-option
                        :label="item.label"
                        :value="item.value"
                        v-for="item in typeList"
                        :key="item.value"
                    />
                </el-select>
            </el-form-item>
        </el-form>
        <div v-show="adjustType == '非故障'">
            <el-icon
                size="14"
                style="margin-right: 5px"
            >
                <WarningFilled />
            </el-icon>确认【非故障】将关闭维修任务
        </div>
        <div v-show="adjustType == '报废'">
            <el-icon
                size="14"
                style="margin-right: 5px"
            >
                <WarningFilled />
            </el-icon>
            确认【报废】将关闭维修任务，并将设备状态至于【已报废】
        </div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="adjustVisible = false">取消</el-button>
                <el-button
                    type="primary"
                    @click="adjusConfirm"
                >
                    确认
                </el-button>
            </div>
        </template>
    </el-dialog>

    <el-dialog
        v-model="checkAcceptVisible"
        title="验收"
        width="600"
    >
        <el-form label-width="120">
            <el-form-item
                label="已选任务数量："
                prop="acceptRes"
                v-if="checkAcceptType == 'batch'"
            >
                {{ rowDataList.length }}
            </el-form-item>
            <el-form-item
                label="验收结果："
                prop="acceptRes"
            >
                <el-radio-group v-model="acceptRes">
                    <el-radio label="验收通过">验收通过</el-radio>
                    <el-radio label="验收不通过">验收不通过</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item
                label="验收意见："
                prop="acceptDesc"
            >
                <el-input
                    v-model="acceptDesc"
                    type="textarea"
                ></el-input>
            </el-form-item>
        </el-form>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="checkAcceptVisible = false">取消</el-button>
                <el-button
                    type="primary"
                    @click="checkAcceptConfirm"
                >
                    确认
                </el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog
        v-model="reportTaskVisible"
        title="填报"
        width="800"
    >
        <el-form
            label-width="120"
            :model="ruleFormReport"
            :rules="rulesReport"
            ref="formReport"
            :inline="true"
        >
            <el-form-item
                label="故障描述："
                prop="failureDesc"
            >
                <el-input
                    v-model="ruleFormReport.failureDesc"
                    placeholder="请输入故障描述"
                    style="width: 488px"
                ></el-input>
            </el-form-item>
            <el-form-item
                label="润滑油、脂："
                prop="lube"
            >
                <el-input
                    v-model="ruleFormReport.lube"
                    placeholder="请输入润滑油、脂"
                ></el-input>
            </el-form-item>
            <el-form-item
                label="机封："
                prop="mechanicalSeal"
            >
                <el-input
                    v-model="ruleFormReport.mechanicalSeal"
                    placeholder="请输入机封"
                ></el-input>
            </el-form-item>
            <el-form-item
                label="轴承："
                prop="bearing"
            >
                <el-input
                    v-model="ruleFormReport.bearing"
                    placeholder="请输入轴承"
                />
            </el-form-item>
            <el-form-item
                label="其他："
                prop="other"
            >
                <el-input
                    v-model="ruleFormReport.other"
                    placeholder="请输入其他"
                ></el-input>
            </el-form-item>
            <el-form-item
                label="图片："
                prop="fileList"
            >
                <el-upload
                    v-model:file-list="ruleFormReport.fileList"
                    action="#"
                    :http-request="
                        (file) => {
                            httpRequest(file, index);
                        }
                    "
                    list-type="picture-card"
                    :on-remove="
                        (file) => {
                            handleRemove(file, index);
                        }
                    "
                    :on-preview="handlePictureCardPreview"
                    accept=".png,.jpg"
                    :limit="3"
                >
                    <el-icon>
                        <Plus />
                    </el-icon>
                </el-upload>
            </el-form-item>
        </el-form>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="reportTaskVisible = false">取消</el-button>
                <el-button
                    type="primary"
                    @click="reportTaskConfirm"
                >
                    确认
                </el-button>
            </div>
        </template>
    </el-dialog>
</template>

<script setup>
import equipmentHttp from "@/https/equipment.js";
import schedulingHttp from "@/https/scheduling.js";
import userHttp from "@/https/user.js";
import Storage from "@/utils/storage.js"; // storage工具类，简单的封装
import {
    Plus,
    WarningFilled
} from "@element-plus/icons-vue";
import { ElMessage } from "element-plus";
import moment from "moment";
import { onMounted, reactive, ref, watch } from "vue";
let searchForm = reactive({
    acceptanceStatus: "",
    facilityName: "",
    assetNumber: "",
    dateTime: [],
    pageNo: 1,
    pageSize: 10,
});
const depIdList = ref([
    { label: "全部", value: "1" },
    { label: "星沙厂", value: "2" },
    { label: "城西厂", value: "3" },
    { label: "城北厂", value: "4" },
    { label: "城南厂", value: "5" },
    { label: "城东厂", value: "6" },
]);
const acceptanceStatusList = ref([
    { label: "全部", value: "" },
    { label: "未到达验收", value: "10" },
    { label: "待验收", value: "90" },
    { label: "已验收", value: "100" },
]);
const statusList = ref([
    { label: "全部", value: "" },
    { label: "未分配", value: "0" },
    { label: "进行中", value: "10" },
    { label: "已完成", value: "90" },
    { label: "关闭", value: "100" },
    { label: "未通过", value: "99" },
]);
const statusName = (id) => {
    return id == "0"
        ? "未分配"
        : id == "10"
            ? "进行中"
            : id == "90"
                ? "已完成"
                : id == "100"
                    ? "关闭"
                    : id == "99"
                        ? "未通过"
                        : "";
};
const upkeepLevelName = (id) => {
    return id == "10"
        ? "未到达验收"
        : id == "90"
            ? "待验收"
            : id == "100"
                ? "已验收"
                : "";
};
const localTypeUnit = ref(Storage.localGet("depId"));
searchForm.depId = localTypeUnit.value;

const recordListVisible = ref(false);
const adjustVisible = ref(false);

let ruleForm = reactive({
    region: "",
    name: "",
    desc: "",
    continuous: "",
    value1: [],
    type11: "class",
    number: 1,
    dayNumber: 1,
    monthNumber: 1,
    weekNumber: "1",
    week: "Mon",
    inspectionType: "固定人员",
});
const tableData = ref([{ name: 1 }]);
const adjustType = ref("");
const inspectionType = ref("固定人员");
const inspectionUser = ref("");
const typeList = ref([]);
const adjustTime = ref(moment().format("YYYY-MM-DD"));
const adjustStatus = ref("100");

const classesShowList = ref([]);
// 查询班次信息
const getWorkClassQueryWorkClassShow = async (row) => {
    let params = {
        depId: row.depId,
        classType: "1",
        isDelete: "0",
        pageNo: 1,
        pageSize: 1000,
    };
    const res = await schedulingHttp.workClassQueryWorkClass(params);
    if (res.data.code == 200) {
        res.data.data.records.forEach((item) => {
            item.label = item.className;
            item.shortLabel = item.classShortName + "";
            item.value = item.id + "";
            item.statusTrigger = false;
        });
        classesShowList.value = res.data.data.records;
    }
};
const userList = ref([]);
const userQueryUserList = async (row) => {
    let params = {
        depId: row.depId,
        isDelete: 0,
        pageNo: 1,
        pageSize: 10000,
    };
    const res = await userHttp.userQueryUserList(params);
    if (res.data.code == 200) {
        res.data.data.records.forEach((item) => {
            item.label = item.realName;
            item.value = item.id + "";
        });
        userList.value = res.data.data.records;
        typeList.value = userList.value;
    }
};
const groupList = ref([]);
// 查询班组信息
const getWorkteamsQueryWorkTeams = async (row) => {
    let params = {
        depId: row.depId,
        pageNo: 1,
        pageSize: 10000,
    };
    const res = await schedulingHttp.workteamsQueryWorkTeams(params);
    if (res.data.code == 200) {
        res.data.data.records.forEach((item) => {
            item.label = item.teamName;
            item.value = item.id;
        });
        groupList.value = res.data.data.records;
    }
};
watch(
    inspectionType,
    (val) => {
        if (val == "当日值班班组") {
            typeList.value = classesShowList.value;
        } else if (val == "固定班组") {
            typeList.value = groupList.value;
        } else if (val == "固定人员") {
            typeList.value = userList.value;
        }
    },
    { deep: true }
);
const adjustStatusList = ref([
    { label: "未开始", value: "0" },
    { label: "进行中", value: "10" },
    { label: "已完成", value: "100" },
]);
const adjustList = ref([
    { label: "确认故障", value: "确认故障" },
    { label: "非故障", value: "非故障" },
    { label: "报废", value: "报废" },
]);
const currentRowData = ref();
const optionAdjust = (row) => {
    getWorkClassQueryWorkClassShow(row);
    getWorkteamsQueryWorkTeams(row);
    userQueryUserList(row);
    adjustVisible.value = true;
    adjustType.value = "";
    inspectionUser.value = "";
    inspectionType.value = "固定人员";
    adjustTime.value = moment().format("YYYY-MM-DD");
    adjustStatus.value = "100";
    currentRowData.value = row;
};
const adjusConfirm = async () => {
    let params = {
        id: "",
        processingResult: "",
        nextUser: "",
    };
    console.log(currentRowData.value);
    params.id = currentRowData.value.id;
    params.processingResult = adjustType.value;
    params.nextUser = inspectionUser.value;
    const res = await equipmentHttp.equipRepairProcessing(params);
    console.log(res);
    if (res.data.code == 200) {
        ElMessage({
            type: "success",
            message: "处理成功",
        });
        search();
        adjustVisible.value = false;
    } else {
        ElMessage({
            type: "error",
            message: "处理失败",
        });
    }
};
const activeName = ref("");

const roleNames = ref(Storage.localGet("roleNames"));
const isAdmin = ref(false);
const isEquipmentManager = ref(false);
isAdmin.value =
    roleNames.value.includes("sysadmin") || roleNames.value.includes("admin");
isEquipmentManager.value = roleNames.value.includes("设备负责人");
console.log(isAdmin.value, "isAdmin.value");
// 验收
const checkAcceptVisible = ref(false);
const checkAcceptType = ref("");
const acceptRes = ref("");
const acceptDesc = ref("");
const optionCheckAccept = (row) => {
    checkAcceptVisible.value = true;
    checkAcceptType.value = "single";
    acceptRes.value = "";
    acceptDesc.value = "";
    currentRowData.value = row;
    console.log(currentRowData.value.id);
};
const checkAcceptConfirm = async () => {
    if (acceptRes.value == "") {
        ElMessage({
            type: "warning",
            message: "请选择验收结果",
        });
        return;
    }
    let params = {
        ids: "",
        result: "",
        remark: "",
    };
    params.result = acceptRes.value;
    params.remark = acceptDesc.value;
    console.log(checkAcceptType.value, currentRowData.value.id);
    if (checkAcceptType.value == "batch") {
        let idsArr = [];
        rowDataList.value.forEach((item) => {
            item.acceptanceStatus != "90";
            isCheckAccept = false;
            idsArr.push(item.id);
        });
        params.ids = idsArr.join(",");
    } else if (checkAcceptType.value == "single") {
        params.ids = currentRowData.value.id;
    }
    const res = await equipmentHttp.equipRepairBatchAcceptance(params);
    if (res.data.code == 200) {
        console.log(res.data.data);
        search();
        checkAcceptVisible.value = false;
        ElMessage({
            type: "success",
            message: "验收成功",
        });
    } else {
        ElMessage({
            type: "error",
            message: res.data.data.msg,
        });
    }
};
// 批量验收
const batchCheckAccept = async () => {
    console.log("batchEdit");
    checkAcceptType.value = "batch";
    if (rowDataList.value.length > 0) {
        let isCheckAccept = true;
        let ids = "";
        let idsArr = [];
        rowDataList.value.forEach((item) => {
            if (item.acceptanceStatus != "90") {
                isCheckAccept = false;
            }
            idsArr.push(item.id);
        });
        ids = idsArr.join(",");
        if (isCheckAccept) {
            checkAcceptVisible.value = true;
        } else {
            ElMessage({
                message: `所选数据中有‘未达验收’或‘已验收’的数据`,
                type: "warning",
            });
        }
    } else {
        ElMessage({
            message: "请至少勾选一条数据",
            type: "warning",
        });
    }
};

const handleClick = (name) => {
    console.log(name);
};
const activeEq = ref({});
const currentTask = ref({});
// 填报
const reportTaskDataList = ref([]);
const reportTaskVisible = ref(false);
const ruleFormReport = reactive({
    equipId: "",
    id: "",
    imageIds: "",
    failureDesc: "",
    lube: "",
    other: "",
    mechanicalSeal: "",
    bearing: "",
    urlList: [],
    fileList: [],
});

const rulesReport = reactive({
    failureDesc: [
        {
            required: true,
            message: "请输入故障描述",
            trigger: "blur",
        },
    ],
    lube: [
        {
            required: true,
            message: "请输入润滑油、脂",
            trigger: "blur",
        },
    ],
    other: [
        {
            required: true,
            message: "请输入其他",
            trigger: "blur",
        },
    ],
    mechanicalSeal: [
        {
            required: true,
            message: "请输入机封",
            trigger: "blur",
        },
    ],
    bearing: [
        {
            required: true,
            message: "请输入轴承",
            trigger: "blur",
        },
    ],
});
const reportTask = async (row) => {
    reportTaskVisible.value = true;
    currentTask.value = row;
    ruleFormReport.equipId = currentTask.value.equipId;
    ruleFormReport.id = currentTask.value.id;
    ruleFormReport.bearing = "";
    ruleFormReport.mechanicalSeal = "";
    ruleFormReport.other = "";
    ruleFormReport.failureDesc = "";
    ruleFormReport.lube = "";
    ruleFormReport.imageIds = "";
    ruleFormReport.urlList = [];
    ruleFormReport.fileList = [];
};
const uploadImgCount = ref(0);
const formReport = ref();
const httpRequest = (params, index) => {
    console.log(params, index, "httpRequest");
    uploadImgCount.value++;
    schedulingHttp.fileInfoUpload(params).then((res) => {
        if (res.data.code == 200) {
            console.log(res.data, "1111111");
            ruleFormReport.urlList.push({
                fileName: res.data.data.fileName,
                url: res.data.data.url,
                id: res.data.data.id,
            });
            uploadImgCount.value--;
            ElMessage({
                type: "success",
                message: "上传成功",
            });
        }
    });
};
const reportTaskConfirm = async () => {
    if (uploadImgCount.value > 0) {
        ElMessage({
            type: "error",
            message: "请等待图片上传成功",
        });
        return;
    }
    ruleFormReport.urlList.forEach((item) => {
        let imgids = [];
        if (ruleFormReport.urlList.length > 0) {
            ruleFormReport.urlList.forEach((m) => {
                imgids.push(m.id);
            });
            ruleFormReport.imageIds = imgids.join(",");
        } else {
            ruleFormReport.imageIds = "";
        }
    });
    console.log(ruleFormReport, "ruleFormReport");
    if (!formReport.value) return;
    await formReport.value.validate((valid, fields) => {
        if (valid) {
            equipmentHttp
                .equipRepairReportRepair(ruleFormReport)
                .then((res) => {
                    if (res.data.code == "200") {
                        reportTaskVisible.value = false;
                        ElMessage({
                            type: "success",
                            message: "填报成功",
                        });
                        search();
                    } else {
                        ElMessage({
                            type: "error",
                            message: "填报失败",
                        });
                    }
                });
        } else {
            ElMessage({
                type: "error",
                message: "请完善填报信息",
            });
        }
    });
};
let total = ref(0);
const handleSizeChange = (val) => {
    searchForm.pageSize = val;
    search();
};
const handleCurrentChange = (val) => {
    searchForm.pageNo = val;
    search();
};
const search = async () => {
    let params = {
        ...searchForm,
        startTime: searchForm.dateTime[0]
            ? moment(searchForm.dateTime[0]).format("YYYY-MM-DD")
            : "",
        endTime: searchForm.dateTime[1]
            ? moment(searchForm.dateTime[1]).format("YYYY-MM-DD")
            : "",
    };
    const res = await equipmentHttp.equipRepairQueryRepair(params);
    console.log(res);
    if (res.data.code == 200) {
        tableData.value = res.data.data.records;
        total.value = res.data.data.total;
    }
};
const reset = () => {
    searchForm.facilityName = "";
    searchForm.depId = localTypeUnit.value;
    searchForm.acceptanceStatus = "";
    searchForm.assetNumber = "";
    searchForm.dateTime = [];
    searchForm.pageNo = 1;
    searchForm.pageSize = 10;
    search();
};

const recordTime = ref([]);
const recordList = ref([]);
const currentRowRecord = ref();
const optionRecord = async (row) => {
    recordListVisible.value = true;
    currentRowRecord.value = row;
    recordTime.value[0] = moment().format("YYYY-MM-DD");
    recordTime.value[1] = moment().add(1, "day").format("YYYY-MM-DD");
    searchRecord(currentRowRecord.value);
};
const recordPageNo = ref(1);
const recordPageSize = ref(10);

let totalRecord = ref(0);
const handleSizeChangeRecord = (val) => {
    recordPageSize.value = val;
    searchRecord(currentRowRecord.value);
};
const handleCurrentChangeRecord = (val) => {
    recordPageNo.value = val;
    searchRecord(currentRowRecord.value);
};
const searchRecord = async (row) => {
    let params = {
        businessId: row.id,
        operationType: "",
        businessType: "设备维修",
        startTime:
            recordTime.value.length > 0
                ? moment(recordTime.value[0]).format("YYYY-MM-DD")
                : "",
        endTime:
            recordTime.value.length > 0
                ? moment(recordTime.value[1]).format("YYYY-MM-DD")
                : "",
        pageNo: recordPageNo.value,
        pageSize: recordPageSize.value,
    };
    const res = await schedulingHttp.operationRecordsQueryOperationRecords(
        params
    );
    console.log(res);
    if (res.data.code == 200) {
        recordList.value = res.data.data.records;
        totalRecord.value = res.data.data.total;
    }
};
let rowDataList = ref([]);
const handleSelectionChange = (rowData) => {
    console.log(rowData);
    rowDataList.value = rowData;
};
const updateTask = () => { };
const getRowKey = (row) => {
    return row.id;
};
const multipleTableRef = ref()
const clearSelect = () => {
    multipleTableRef.value.clearSelection();
};
onMounted(() => {
    search();
});
</script>

<style scoped lang="less">
.filter {
    flex-wrap: wrap;
    display: flex;
    flex-direction: row;
    align-items: center;
    .filter-item {
        margin: 0 15px 15px 0px;
        display: flex;
        flex-direction: row;
        align-items: center;
        label {
            font-size: 14px;
            color: #333;
            display: inline-block;
            white-space: nowrap;
        }
    }
}
.reportLabel {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 60px;
    p {
        line-height: 1.5;
    }
}
:deep .el-dialog__body {
    padding: 20px !important;
}
:deep .el-tabs__item {
    height: 70px !important;
}
.projectBox {
    padding: 0 20px;
    p {
        font-size: 16px;
        margin-bottom: 10px;
    }
    ul li {
        line-height: 1.5;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}
.choiceListNumb {
    line-height: 32px;
    display: flex;
    flex-direction: row;
    align-items: center;
    span {
        margin-right: 10px;
    }
}
</style>